using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class br_TransMap : EntityTypeConfiguration<br_Trans>
    {
        public br_TransMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Title, t.level1, t.level2, t.template, t.Description, t.type, t.Project, t.sort, t.FunctionCode, t.options });

            // Properties
            this.Property(t => t.Title)
                .IsRequired()
                .HasMaxLength(54);

            this.Property(t => t.level1)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.level2)
                .IsRequired()
                .HasMaxLength(19);

            this.Property(t => t.template)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Description)
                .IsRequired()
                .HasMaxLength(49);

            this.Property(t => t.type)
                .IsRequired()
                .HasMaxLength(1);

            this.Property(t => t.Project)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.sort)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.FunctionCode)
                .IsRequired()
                .HasMaxLength(7);

            this.Property(t => t.options)
                .IsRequired()
                .HasMaxLength(8);

            // Table & Column Mappings
            this.ToTable("br_Trans");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.level1).HasColumnName("level1");
            this.Property(t => t.level2).HasColumnName("level2");
            this.Property(t => t.template).HasColumnName("template");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.type).HasColumnName("type");
            this.Property(t => t.Project).HasColumnName("Project");
            this.Property(t => t.sort).HasColumnName("sort");
            this.Property(t => t.FunctionCode).HasColumnName("FunctionCode");
            this.Property(t => t.options).HasColumnName("options");
        }
    }
}
